package ru.acme.lab16;

import java.util.Scanner;
import ru.acme.lab16.domain.account.CheckingAccount;
import ru.acme.lab16.domain.account.SavingAccount;
import ru.acme.lab16.domain.bank.Bank;
import ru.acme.lab16.domain.client.Client;
import ru.acme.lab16.domain.client.ClientRegistrationListener;
import ru.acme.lab16.domain.client.Gender;
import ru.acme.lab16.service.bank.BankReport;
import ru.acme.lab16.service.bank.BankService;


public class BankApplication {
	
	public static void main(String[] args) {
		Bank bank = new Bank(new ClientRegistrationListener[] {
				new Bank.EmailNotificationListener(), new Bank.PrintClientListener()});
			
		BankService.addClient(bank, new Client("A", Gender.MALE, new SavingAccount(30)));
		BankService.addClient(bank, new Client("B", Gender.MALE, new SavingAccount(30)));
		BankService.addClient(bank, new Client("C", Gender.FEMALE, new SavingAccount(30)));
		BankService.addClient(bank, new Client("D", Gender.FEMALE, new SavingAccount(30)));
		BankService.addClient(bank, new Client("F", Gender.MALE, new SavingAccount(30)));
		BankService.addClient(bank, new Client("G", Gender.MALE, new CheckingAccount(30, 20)));
		BankService.addClient(bank, new Client("H", Gender.FEMALE, new CheckingAccount(30, 20)));
		BankService.addClient(bank, new Client("I", Gender.FEMALE, new CheckingAccount(30, 20)));
		BankService.addClient(bank, new Client("J", Gender.MALE, new CheckingAccount(30, 20)));
		BankService.addClient(bank, new Client("K", Gender.MALE, new CheckingAccount(30, 20)));
		
		BankService.modifyBank(bank);

		boolean statistics = false;
		for (String arg : args) {
			if (arg.equals("-statistics")) {
				statistics = true;
				break;
			}
		}
		if (statistics) {
			Scanner scanner = new Scanner(System.in);
			while (scanner.hasNext()) {
				String command = scanner.nextLine();
				if (command.equals("getClientsCount")) {
					System.out.println(BankReport.getClientsCount(bank));
					continue;
				}
				if (command.equals("getAccountsCount")) {
					System.out.println(BankReport.getAccountsCount(bank));
					continue;
				}
				if (command.equals("getAccountsSortedByBalance")) {
					System.out.println(BankReport.getAccountsSortedByBalance(bank));
					continue;
				}
				if (command.equals("getBankCredit")) {
					System.out.println(BankReport.getBankCredit(bank));
					continue;
				}
				if (command.equals("getClientAccountsMap")) {
					System.out.println(BankReport.getClientAccountsMap(bank));
					continue;
				}
				if (command.equals("exit")) {
					break;
				}
				System.out.println("Bad command");
			}
		}
	}

}
